home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
glass
/
glass.lha
/
GLASS
/
dtm
/
test7.gl
< prev
next >
Wrap
Text File
|
1991-06-18
|
1KB
|
39 lines
Basetype E;
Atom
and5 :- E^5 => E,
and4 :- E^4 => E,
and3 :- E^3 => E,
and2 :- E & E => E,
not :- E => E,
nand :- E & E => E,
nand3 :- E & E & E => E,
ornot :- E & E => E,
or :- E & E => E,
jkff :- E & E & E => E,
buf :- E => E;
Def
counter :- E^9 => E^5;
counter [ck,d3,d2,d1,d0,nload,nclear,enap,enat] = [carry,q3,q2,q1,q0]
where
carry = and5 [q3,q2,q1,q0,enat];
q3 = counterstage [d3, preset, and4 [q2,q1,q0, en], nclr, nck];
q2 = counterstage [d2, preset, and3 [q1,q0,en], nclr, nck];
q1 = counterstage [d1, preset, and2 [q0,en], nclr, nck];
q0 = counterstage [d0, preset, en, nclr, nck];
preset = ornot [nload, nclr];
nclr = buf nclear;
en = and2 [enap,enat];
nck = not ck;
Mac
counterstage :- E^5 => E;
counterstage [d, preset, toggle, nclr, nck] =
jkff [nck, and2 [ja, ea], and2 [ka, ea]]
where
ja = nand [ka, preset];
ka = nand3 [d, preset, nclr];
ea = or [toggle, preset]
endwhere;
endwhere;